#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int GetDays(int y, int m)
{
	int day = 0;
	int ArrDays[13] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	day = ArrDays[m];
	if ((m == 2) && (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)))
	{
		day = 29;
	}
	return day;
}

int main()
{
	int year = 0;
	int month = 0;
	scanf("%d %d", &year, &month);
	int ret = GetDays(year, month);
	printf("%d\n", ret);
	return 0;
}